﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace WeatherStation
{
    class MainClass
    {
        private WeatherData Station;
        private const int SleepInterval = 1000;
        private Random rnd;
        
        public static void Main(string[] s)
        {           
            MainClass MC = new MainClass();
            MC.Init();          
        }

        private void Init()
        {
            // Instantiate WD & Registrate Observers
            Station = new WeatherData();
            CurrentConditionsDisplay CCD = new CurrentConditionsDisplay(Station);
            ForcastDisplay FD = new ForcastDisplay(Station);
            StatisticsDisplay SD = new StatisticsDisplay(Station);
                                    
            rnd = new Random();             

            Thread WDThread = new Thread(new ThreadStart(this.xStart));
            WDThread.Start();
        }

        public void xStart()
        {
            while (Thread.CurrentThread.IsAlive)
            {                              
                Station.SetMeasurements((float)rnd.NextDouble() * 60 - 15, (float)rnd.NextDouble() * 100, (float)rnd.NextDouble() * 1000);
                Thread.Sleep(SleepInterval);
            }
        }
    }
}